<template>
  <div class="header">
    <slot name="back">
    </slot>
    <h1>
      猫眼电影
    </h1>
    <div class="nav">
      <span @click.stop="SET_SHOW_NAV(!showNav)">...</span>
      <ul v-if="showNav">
        <li @click="go('/index/movie/hotshowing')">
          电影
        </li>
        <li @click="go('/index/theater')">
          影院
        </li>
        <li @click="go('/index/profile')">
          我的
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex"
export default {
  data() {
    return {
    }
  },
  computed: {

    ...mapState(["showNav"])
  },
  methods: {
    ...mapMutations(["SET_SHOW_NAV"]),
    go(url) {
      this.$router.push(url)
      this.SET_SHOW_NAV(!this.showNav); 
    }
  }
}
</script>



<style lang="scss" scoped>
.header {
  height: 50px;
  background: #e54847;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  h1 {
    font-size: 18px;
    color: white;
    flex: 1;
    font-weight: 300;
  }

  .nav {
    width: 50px;
    font-size: 25px;
    color: white;
    height: 50.5px;
    line-height: 38px;
    position: relative;
    ul {
      position: absolute;
      z-index: 1;
      top: 50px;
      right: 0px;
      background: white;
      width: 75px;
      color: #000;
      font-size: 14px;
    }
  }
}
</style>

